package educrypt.gui.components;

import java.awt.event.ActionListener;

import educrypt.gui.view.ConsoleSmallView;
import educrypt.gui.view.CryptanalysisOptionsView;
import educrypt.gui.view.CryptanalysisResultView;
import educrypt.gui.view.CryptanalysisView;
import educrypt.gui.view.TextOptionsView;
import educrypt.gui.view.TextView;

class CryptanalysisPanel extends EducryptPanel implements CryptanalysisView {

	private static final long serialVersionUID = 3173078410392954249L;

	private TextPanel textSubPanel;
	private TextOptionsPanel textOptionsSubPanel;
	private CryptanalysisOptionsPanel optionsSubPanel;
	private CryptanalysisResultPanel resultSubPanel;
	private ConsoleSmallPanel consoleSubPanel;

	public CryptanalysisPanel() {
		this.setSize(740, 600);
		this.setPreferredSize(this.getSize());
		setLayout(null);

		textSubPanel = new TextPanel();
		textSubPanel.setBounds(0, 0, 740, 80);
		textSubPanel.setCryptanalysisContext();
		this.add(textSubPanel);

		textOptionsSubPanel = new TextOptionsPanel();
		textOptionsSubPanel.setBounds(0, 80, 740, 80);
		textOptionsSubPanel.setCryptAnalysisContext();
		this.add(textOptionsSubPanel);

		optionsSubPanel = new CryptanalysisOptionsPanel();
		optionsSubPanel.setBounds(0, 160, 740, 80);
		this.add(optionsSubPanel);

		resultSubPanel = new CryptanalysisResultPanel();
		resultSubPanel.setBounds(0, 240, 740, 240);
		this.add(resultSubPanel);

		consoleSubPanel = new ConsoleSmallPanel();
		consoleSubPanel.setBounds(0, 480, 740, 170);
		this.add(consoleSubPanel);
	}

	@Override
	public void addListener(ActionListener ctr) {
		textSubPanel.addListener(ctr);
		textOptionsSubPanel.addListener(ctr);
		optionsSubPanel.addListener(ctr);
		resultSubPanel.addListener(ctr);
		// consoleSubPanel listener defined in EducryptCtr
	}

	/* Getters */
	@Override
	public TextView getTextPanel() {
		return textSubPanel;
	}

	@Override
	public TextOptionsView getTextOptionsPanel() {
		return textOptionsSubPanel;
	}

	@Override
	public CryptanalysisOptionsView getOptionsPanel() {
		return optionsSubPanel;
	}

	@Override
	public CryptanalysisResultView getCryptanalysisResultPanel() {
		return resultSubPanel;
	}

	@Override
	public ConsoleSmallView getConsolePanel() {
		return consoleSubPanel;
	}

	/* END Getters */

}
